I've been working on the Switch Module firmware the past day.
I've managed to get the basics done in the Mega 2560 firmware. It runs, and does basic communication with the ESP8266 code. I've got a few little details to check, but then I'll copy both sets of code into some text files so I can just cut and paste it into a new project if I want to add a new module type, or upgrade the old software on the automatic watering module, which I'm sure I will
I'm switching tasks for a little bit here, I want to revisit the Dual Level Soil Moisture Sensors I came up with, and then dismissed because the readings seemed incoherent at the time. I just wasn't seeing a pattern in the readings.
So far, I hooked the sensor directly to the computer via the arduino pro/mini which is acting like a slave i2c device, and actually reads the probes and sends the data back to the Sensor Module. You can read about it here.
This is the original single probe Soil Moisture Sensor..
As I said, the sensor was hooked directly to the computer using a CP2102 USB to TTL/Serial module so I can program it, and also see the debug info on the serial monitor. I can see that the sensor does actually work, and the readings seem accurate, so now it's time to plug it into a Sensor Module and test it.
The problem is, the new firmware for the Sensor Module doesn't have the code in it to read i2c devices. Since I wasn't using these dual level sensors, I had no other i2c sensors I'm using, so I didn't bother with the code. I'll do that now, and then I can test the sensors again.
Looks like at least this one is working fine, perhaps it was a software issue that has since been fixed?
The yellow highlight is just for my debugging, but you see sensor #64, I have a wet paper tower wrapped around the bottom probe, thats why it only reads bottom. I've tested both. It is dropping as the towel dries out, that's what I was expecting, so it looks good.
Here's the plant I want to try this with first, its a re-veg, after it flowered and I harvested, I cut it back to just some small clusters of green at the base. They grow back with so much vegetation it's crazy...
I transplanted it to a 17L pail the other day, and it is too deep for a single probe to measure accurately, and is an ideal candidate to test the dual probe sensor. Another reason for choosing this plant over the others, which are small clones, is the sheer amount of vegetation will mean it's going to suck up a lot more water, so I should see results faster, including ensuring the patterns of readings are correct. In other words, is the moisture level dropping at the rate I expect, or going up the right amount when it is watered? I've got maybe two weeks till the pumps arrive, so it gives me time to certify this before I set these 4 pails to automatic watering....
I'm not sure what happened, but out of nowhere it stopped working comlpetely. The sensor module can't talk to the i2c slave, and when I try to monitor the serial oputput from the slave, it just doesn't display anything, or it displays garbage, depending where it gets it\s power. I can power the pro/mini from the CP2102 module, or the Sensor Module I2C power pin I provide. I believe its an issue of not having a common ground, although they shouyld via the usb hub. In any case, it's been a long night, I'm tired, my eyes aren't focusing well even with my glasses on, so this isn't the best time to be plugging wires in between boards on a whim... know what I mean?
So, I put that little project in a box till later, which is good, because my attention span, while getting better, is still pretty short. That's probably the main reason I'm always switching tasks and getting sidetracked.
I just realized that when I plugged the pro/mini into the usb hub, it was the usb cable from the sensor module, so there was no common ground, and I was right :) The sensor module was powered by a 12v wall-wart, completely separate from the usb hub.
Providing a common ground did resolve the serial monitor issues, but the Sensor Module was still unable to connect with the pro/mini i2c slave device. I even hooked the pro/mini directly to the Mega 2560's SDA and SCL pins without the shield, still no go. I tried another i2c device, no go... so something on the sensor module, likely software since a direct connection didn't work either. After careful examination, I realized there was no Wire.begin(); anywhere in the code to initialize the i2c connection :( See what happens when you're tired? Ok, when I'm tired...
It's working now, I don't understand how it worked earlier, unless the code had that line, and I mysteriously deleted it...
I've got both Dual Level Soil Moisture Sensors in use now, both in large pails. I can't build any more until I get some more parts from the electronics store in Markham and I'm not sure when we'll be there again. I'll keep an eye on these two for now, but they are looking good so far.
I'm taking advantage of 2 of the 5 statuslines available at the bottom of the terminal program window. They were being used to display the number of records read, written, saved, etc. Now I'm displaying the uptime of each board, the esp8266 and the mega2560 since both can be rebooted individually. Uptime is just how long since the board was rebooted.