Now that I know the sensor works with a standard Arduino Mega, it’s time to try and get it running on The Things Uno.

An Atlas Scientific Conductivity K 1.0 sensor hooked up to The Things Uno

My first attempts getting the Atlas Scientific Uno code running on The Things Uno didn’t get very far. It seemed to be a problem running SoftwareSerial on the default pins 2 & 3.

But when I moved those to pins 10 & 11, I started getting output on the serial monitor! Success.

Next step was to merge that sample code with The Things sample code and see if it all still compiled and ran. More success!

The output from the serial monitor of the Arduino IDE.

The final step is to convert the sensorstring to a byte array so that we can send it to The Things Network.

// Convert sensorstring to a byte array
byte data[sensorstring.length()];
sensorstring.getBytes(data, sizeof(data));

From the TTN docs, the send command to their network is:

// Send the data
ttn.sendBytes(data, sizeof(data));

The complete code is now all up in this GitHub repo:
github.com/sighmon/water-quality-sensors

Exciting!

Leave a comment

Your email address will not be published. Required fields are marked *