One Man's Adventures into Renewal Energy
Please help me to continue hosting this website & associated costs by donating £2.
In return, I'll email you a ZIP file containing arduino code + all images from the website + some extra ones that aren't on the website...all in high res (370MB of pics!).

How to Send Email with Arduino via WiFi Shield

23rd July 2013

Now that I have my shed wired up with Solar, I have a burning desire to monitor how things are going.
I'm especially interested to know things like -

Anyways - Lots of questions to answer and I've decided that I'd like to create a monitor system and send all this data, in real-time, to my website.

I'm going to be using my Arduino to do this.
Using Voltage Dividers and things like that to get the actual data...but before I do all that, I have spent some time on how to get the data from the Arduino, over the internet to my webserver.
I've purchased a SainSmart WiFi Wireless Module Shield WizFi210.

Here it is, plugged into my Arduino
Arduino WiFi Shield

This particular shield is somewhat lacking in online documentation, resulting in me spending several days getting it to do anything.

I decided I didn't want to use any of the Libraries that came with this shield, and instead wanted to talk directly to the shield using AT Commands. I felt this was easier to understand and much easier to tweak the code.

To upload, you need to remove the WiFi shield and upload to Arduino.
When uploaded, power off, fit WiFi shield, make sure Jumpers are set to WIFI (pic above), power on.
You obviously need to ensure the server you are sending emails to allows anonymous connections.
For reference, I'm using IIS6.
I've turned off 'Relaying'. Make sure you do the same. Here is the code -

void setup()  
  // Open serial communications and wait for port to open:

void loop(){
  Serial.print("AT+WD\r\n"); //Disconnect from WiFi if currently connected
  Serial.print("AT+WAUTH=2\r\n"); // set WEP authentication
  Serial.print("AT+WWPA=password\r\n"); // set Passphrase
  Serial.print("AT+WA=SSIDname\r\n"); // The name of your SSID.  This will also force it to connect
  delay(20000); // long pause to wait for connection to Wireless Access Point
  Serial.print("AT+NCTCP=,1234\r\n"); // IPAddress, Port. 
  delay(20000); // probably don't need such a long pause here
  Serial.print("\x1B" "S"); //Send Escape Character and Capital S to initiate 'CID' connection to address above (notice no Carriage Return, Line Feed)
  Serial.print("0\r\n"); //'CID' number.  Should be 0
  Serial.print("MAIL FROM:someoneATsomewhere.ORG\r\n"); // obviously change these to a valid email address
  Serial.print("RCPT TO:someoneATsomewhere.ORG\r\n"); // obviously change these to a valid email address
  Serial.print("\x1B" "E\r\n"); // You have to Escape out of the sequence and back in again in order for the SMTP server to accept data
  Serial.print("\x1B" "S"); // Escape Back in (notice no Carriage Return, Line Feed)
  Serial.print("0\r\n"); // Escape Back in
  Serial.print("some text to send\r\n");
  Serial.print("a bit more\r\n");
  Serial.print("\x1B" "E\r\n"); //Escape Out
  Serial.print("AT+WD\r\n"); //Disconnect from WiFi to conserve power


If you struggle to get it to work, you can set the jumpers to USB.
Upload 'Blink', which is a bundled small ".ino" script for Arduino.
This will allow you to communicate directly with the WiFi shield via a Serial Monitor. Just make sure you set the speed to 115200.

You can test various responses by inputting them directly in the serial monitor application.
EG - AT should get "OK"

You will struggle to send the ESC characters using the Arduino Serial Monitor, so you might want to use "Tera Term", which is a free bit of software that will allow serial communication. Just make sure you set the "New-Line" receive and transmit to "CR+LF" in the Terminal Setup menu.

24th July 2013

I've now got a live feed from the Arduino in my shed, over the internet, to my webserver.
This then writes to a SQL database with the date and volts.
My website then runs this through Google Charts and outputs a nice voltmeter (top right).
Pretty cool I think!!

I struggled like mad to get this to work and now I have got it working, I'd like to offer my experience with this.
If you have any questions what so ever, please ask them below. I'll usually respond within a day.

Next - So now I've decided to build a wind generator!


Daniel - 14/04/2015 00:39:14
We opened WIZnet Museum ( site. If you are O.K. We would like to introduce your projects. Hopefully, you will allow this.

Daniel - 14/04/2015 00:36:05
My name is Daniel, at WIZnet in Korea We have been searching some application references in which WIZnet solution is applied, and found your project using WizFi210 shield.

hh - 14/04/2015 00:30:24

- 28/07/2014 10:26:53
Hi Baseljd. I'm afraid I have no clue. I only really looked into the specific bits I needed to get my monitor to work.

Baseljd - 17/02/2014 15:38:52
Great tutorial! Yeah this shield lacks alot of online documentation :( Any idea how I can POST or GET to a php page on my server and also read from a php post to control something...


Email Address (won't be shown)

Human Check - What colour is the sky?


Copyright 2020