@stevie Thanks! That's useful research. I'll pull out my multimeter and probe things a bit to see where it might be breaking down.
Latest posts made by justindthomas
Can't switch to standalone 12v power
Hi there. I have two of the Eduponics Mini bundles - one with the expansion board. I'm working on configuring one with the expansion board to cycle through 4 connected moisture sensors and report the data regularly back to my own MQTT server. I have it running well when it's connected to the computer via USB; I can reset the board and it comes right up, connects to WiFi, connects to the MQTT server and begins cycling through the sensors to report data as expected.
But as soon as I try to switch over to the 12V power, it starts failing. Even when I leave it connected to the computer and just connect the 12V adapter and flip the "on" switch, it stops working. From the LEDs, it looks like maybe it's trying to start - I see the amber light next to "boot" flash weakly, and the blue light for the first sensor tries to come on weakly as well (flashing like it is running the program). But none of the other sensor lights come on, and nothing gets reported to my MQTT server.
It seems like the 12V power isn't being sent to the right place or something to power the board properly. I tried two different adapters (since I have two kits) and I tried both ESP32 boards with the same results. Any advice?
Here is my
main.pyfile for reference.
import mqtt import machine import time import json from Eduponics import mcp23017,ads1x15 from machine import I2C,Pin power = Pin(12, Pin.OUT) power.value(1) time.sleep(0.1) # define i2c connection to the extension board i2c = I2C(scl=Pin(33), sda=Pin(32)) # setup adc for the extension board (default address for MCP might be 0x20) ads_address = 0x48 mcp_address = 0x27 gain = 1 # adc = ADC(Pin(35)) adc = ads1x15.ADS1115(i2c=i2c, address=ads_address,mcp_address=mcp_address, gain=gain) calibration = ((3640, 32800,"enclosed_long"), (380, 26064,"open_long"), (380, 26176,"open_short")) plants = [("avocado1",0,0), ("avocado2",1,0), ("avocado3",2,1), ("lemon",3,2)] topics = ["esp32/agriculture"] def on_message_callback(topic, msg): ''' get the message and topic and print it ''' print((topic, msg)) def connect_and_subscribe(): print("[-] Connecting to MQTT client ...") # set the MQTT broker object client = mqtt.MQTTClient() # set a callback for incoming messages (subscribed topics) client.set_callback(on_message_callback) # connect to the broker client.connect() # subscribe to the topics for topic in topics: client.subscribe("%s" % topic) print("[-] Subscribed to %s successfully" % topic) print("[-] Connected to %s MQTT broker successfully" % client.server) return client def restart_and_reconnect(): # something went wrong, reconnect in 5 seconds ... print('[-] Failed to connect to MQTT broker. Reconnecting...') time.sleep(5) machine.reset() try: client = connect_and_subscribe() except OSError as e: restart_and_reconnect() # configure few variables last_message = 0 message_interval = 1 while True: try: # check if there are new messages pending to be processed # if there are, redirect them to callback on_message_callback() client.check_msg() # check if the last published data wasn't less than message_interval if (time.time() - last_message) > message_interval: for plant in plants: adc_read = adc.read(plant) voltage = adc_read["voltage"] value = adc_read["raw"] minVal = calibration[plant] maxVal = calibration[plant] moisture = 1.0 - (value - minVal) / (maxVal - minVal) client.publish("esp32/agriculture/%s/moisture_pct" % plant, str(moisture)) client.publish("esp32/agriculture/%s/moisture_raw" % plant, str(value)) print("[-] published %s moisture status: %s" % (plant, str(moisture))) # update last message timestamp last_message = time.time() except OSError as e: # if something goes wrong, reconnect to MQTT server restart_and_reconnect()
I disconnected the expansion board and switched to just reading from one sensor connected directly to the main board. That works fine and I'm able to power that with the 12V adapter and have it report as expected. It seems it's just when the expansion board is involved that there are problems.