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.
Thanks for the expansion board main.py ref Justin. It has helped me better understand the code. I have my Mini working and am now trying to bring up the expansion board. I don't have an answer for you, only some additional hardware info. The +12V on the expansion board only goes to the pump connectors and the interface connectors according to the schematic. Hard to see how this affects USB here. The Mini can generate VCC5V from 2 sources: +12V and USB. From the schematic, USB5V from an external host is diode isolated from VCC5V. The +12V input is down converted to VCC5V and connects to the other side of the isolation diode. VCC5V when using USB only is ~ 4.6V and when +12V is present VCC5V is ~5.1V. The isolation diode drops about 0.5V. VCC5V is then down converted to 3.3V. LED D6, the red one, is driven by VCC5V (VCC5V "Good"). LED D8, near the reset switch, is powered by 3.3V and gated by TXD0. D8 will be on when TXD0 is low. +12V goes to the VCC5V converter, pump connectors and interface connectors. The only "USB" influence should be from the downstream voltage converters. This all assumes the schematics are correct. I know they're not up to date (complete). My Mini / expansion board resets anytime I switch +12V on or off (a good thing). The interface connectors on both boards are a little suspect in that the pins are only soldered on one side to the pads due to cold flow. None of my topside pads have solder on them. I recommend measuring the expansion board side VCC5V with a VOM while slightly flexing the connection and depending on the results possibly re-soldering the top pads / pins. I hope this helps Justin.
@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.