I want to monitor when my plant need to be watered but I don’t have a wifi enabled development board OR I don’t have wifi OR I have wifi but it’s configured with WPA2-enterprise security which can’t be accessed using the basic arduino derived wifi libraries.

This short guide shows you how to connect your sensor to thingspeak using the PC as a gateway.

microcontroller dev board -> PC -> thingspeak


  • A sensor – I’m using the moisture sensor from my IOT Plant Monitor but you could really use anything. I’m going to read an analog value.
  • A microcontroller – this will work with pretty much any arduino compatible device or ti device (via energia). I won’t judge either way.
  • A computer – Windows/macos/linux, you just need to change your port identifier, install python and

 How to:img_56de499e897f5

I have connected by moisture sensor into analog input 27. (get the energia pin numbers from here)

img_56de49b0daf8eThis could be A0-A5 if you’re using an arduino UNO

Microcontroller code:


int sensorPin = 24; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor\

void setup() {

void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
float scaledValue = ((((2600.0 - 1400.0) - (sensorValue - 1400.0))/(2600.0 - 1400.0)) * 100.0);




That should be pretty self explanatory. Start a serial connection, read the sensor value, scale it to something useful, send it to serial, delay for 5 minutes (300 seconds).

Python PC code:



import serial
import httplib

ser = serial.Serial('COM4')
ser.baudrate = 115200
temp = ''
while True:
ch =
if ch == '\n':
print temp
conn = httplib.HTTPConnection('')
conn.request("GET", "/update?key=WRITEAPIKEY&%s\n" %(temp) )
res = conn.getresponse()
print res.status, res.reason
temp = ''
temp += ch

This code should be straightforward too. Open a serial connection (replace COM4 with the comm port the microcontroller is connected to), when there is serial data, wait until a new line (\n) and send the text to thingspeak.

You will need to add your writeAPI key to the string.

The data from the microcontroller needs to be in the format:


Save the above code as a .py file and run it, you may need to install the serial and httplib python libraries.

Every time the python code receives data it should print it to the console.

If all is successful then you should see data appearing on thingspeak: