HackySoc: sending and receiving messages

Once HackySoc is installed and configured for your WIFI and email account settings, you can attempt to run the default example. At the time of writing, HackySoc offers two key methods:

bool sendMessage(String recipient, String subject, String body);
bool getNewMessage(void);

sendMessage will send a new email. You only need specify the recipient, the subject and the body.

getNewMessage will retrieve the oldest message that exists in the queue. To get all messages, keep calling getNewMessage until no messages are left. Each time a message is retrieved it is deleted from the server.

In the below code, the WIFI connection is first checked. If a WIFI connection exists, the code checks for new messages. If there are no new messages, the code sends an email asking for a new message :). This process repeats every 5 seconds (be careful: you may end up sending out many email messages).

void loop() {

  // Check that we are still connected to WIFI Access Point
  if ( !wifi.checkAP() ) {
    Serial.println("RE-connecting to WIFI...");
    hackySoc.connectToAP(SSID, PASSWORD);
  } else {
    // We are connected. Check to see if there is a new message
    if ( hackySoc.getNewMessage() ) {
    } else {
      // there are no new messages, send an email requesting a message!
      hackySoc.sendMessage( "myfriend@somewhere.com", "I'm lonely", "Do please send me a message, so that I can test HackySoc!");


If you are experiencing problems, the first port of call is opening up the Arduino IDE’s Serial Monitor (Tools>Serial Monitor). Any issues with WIFI connectivity or EMail functionality should be reported here.