Project tutorial
Automation of solar screen

Automation of solar screen

Optimizing the passive solar gain based on current sensor data and weather predictions

    • 5 respects

    Components and supplies

    About this project

    The idea

    The idea is to implement smart control of solar screens: based on indoor temperature, actual solar incidence (measured), weather predictions (e.g. retrieved from a web service) and some simple policies the screens should go up/down, in such way that the level of additional heating (from fossil fuels,...) can be minimised. A (well-insulated) house can be seen as a "heat-capacitor", which you want to see filled just at the right level: buffer sufficient heat in order to minimize the amount of additional heating needed, but don't overfill the buffer so the house gets too warm (and might require active cooling).

    Example policies: if tomorrow will be cold and rainy, allow the sun to heat up the room to 23 deg Celsius (so no heating will be needed tomorrow); if it will be sunny and warm tomorrow, block the sun as soon as the indoor temperature hits 20 deg (to avoid overheating).

    Manual override, and remote monitoring/control would be accessible from a smartphone application.  For the actual control of the solar screens, being able to send the RF signals as produced by the current remote (Somfy Telis) would be great, but for the basic experiment (done in the scope of a hackathon), a Fibaro roler shutter control unit (Z-wave based) is used.

    Only the very basics of this idea are covered in the project below - please note that below is a proof of concept implementation, not a fully completed project.

    Basic implementation

    An kit was used; in a basic set-up, just two temperature sensors are used as input (as well as a LED output - which is not really used). 

    Also, a Roller Shutter gateway device custom-built by AllThingsTalk is used which exposes a motor control actuator out of the box.

    Once the sensor inputs are brought to the platform, the platform is used to trigger the shutter actuator based on the temperature values.

    In order to complete the project, more complex rules need to be added. Additionally, the weather predictions should be retrieved from an online weather service.


    Code snippet to take in the inputs.
    #include <Ethernet.h>
    #include <EthernetClient.h>
    #include <PubSubClient.h>
    #include <math.h>
    #include <ATT_IOT.h>
    #include <SPI.h>                //required to have support for signed/unsigned long type.
      AllThingsTalk Makers Arduino Example 
      ### Instructions
      1. Setup the Arduino hardware
        - USB2Serial
        - Grove kit shield
        - Potentiometer to A0
        - Led light to D8
      2. Add 'allthingstalk_arduino_standard_lib' library to your Arduino Environment. [Try this guide](
      3. Fill in the missing strings (deviceId, clientId, clientKey, mac) and optionally change/add the sensor & actuator names, ids, descriptions, types
         For extra actuators, make certain to extend the callback code at the end of the sketch.
      4. Upload the sketch
      ### Troubleshooting
      1. 'Device' type is reported to be missing. 
      - Make sure to properly add the arduino/libraries/allthingstalk_arduino_standard_lib/ library
      2. No data is showing up in the cloudapp
      - Make certain that the data type you used to create the asset is the expected data type. Ex, when you define the asset as 'int', don't send strings or boolean values.
    char deviceId[] = "x1ahpNLZkN36AzCOrTv8bT6";
    char clientId[] = "eldpoort";
    char clientKey[] = "nqaahjiluad";
    ATTDevice Device(deviceId, clientId, clientKey);            //create the object that provides the connection to the cloud to manager the device.
    char httpServer[] = "";                  	// HTTP API Server host
    char* mqttServer = "";                   
    int tempInside = 0;                                            // Analog 0 is the input pin + identifies the asset on the cloud platform
    int tempOutside = 1;                                            // Analog 1 is the input pin + identifies the asset on the cloud platform
    int lightOutside = 2;                                            // Analog 2 is the input pin + identifies the asset on the cloud platform
    int ledPin = 8;                                             // Pin 8 is the LED output pin + identifies the asset on the cloud platform
    //required for the device
    void callback(char* topic, byte* payload, unsigned int length);
    EthernetClient ethClient;
    PubSubClient pubSub(mqttServer, 1883, callback, ethClient);
    void setup()
      pinMode(tempInside, INPUT);                                  // initialize the digital pin as an input   
      pinMode(tempOutside, INPUT);                                  // initialize the digital pin as an input 
      pinMode(lightOutside, INPUT);                                  // initialize the digital pin as an input 
      pinMode(ledPin, OUTPUT);                                  // initialize the digital pin as an output  
      Serial.begin(9600);                                   	// init serial link for debugging
      byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0x40, 0xB7};        // Adapt to your Arduino MAC Address  
      if (Ethernet.begin(mac) == 0)                             // Initialize the Ethernet connection:
        Serial.println(F("DHCP failed,end"));
        while(true);                                    		//we failed to connect, halt execution here. 
      delay(1000);                                          	//give the Ethernet shield a second to initialize:
      if(Device.Connect(&ethClient, httpServer))                //connect the device with the IOT platform.
        //Device.AddAsset(knobPin, "knob", "rotary switch",false, "int");
        Device.AddAsset(tempInside, "TempInside", "Inside temperature",false, "int");
        Device.AddAsset(tempOutside, "TempOutside", "Outside temperature",false, "int");
        Device.AddAsset(lightOutside, "LightOutside", "Outside ligh intensity",false, "int");
        Device.AddAsset(ledPin, "led", "light emitting iode", true, "bool");
        Device.Subscribe(pubSub);                               // make certain that we can receive message from the iot platform (activate mqtt)
        while(true);                                            //can't set up the device on the cloud, can't continue, so put the app in an ethernal loop so it doesn't do anything else anymore.                              
    unsigned long time;                                 		//only send every x amount of time.
    float prevVal, prevVal2, prevVal3 =0;
    void loop()
      unsigned long curTime = millis();
      if (curTime > (time + 1000))                          	// publish light reading every 1 seconds 
        float tempRead = analogRead(tempInside);           // read from light sensor (photocell)
        float tempRead2 = analogRead(tempOutside);           // read from light sensor (photocell)
        float lightRead = analogRead(lightOutside);           // read from light sensor (photocell)
        if(prevVal != tempRead){
          Device.Send(String((int)tempRead), tempInside);
          prevVal = tempRead;
        if(prevVal2 != tempRead2){
          Device.Send(String((int)tempRead2), tempOutside);
          prevVal2 = tempRead2;
        if(prevVal3 != lightRead){
          Device.Send(String((int)lightRead), lightOutside);
          prevVal3 = lightRead;
        time = curTime;
    // Callback function: handles messages that were sent from the iot platform to this device.
    void callback(char* topic, byte* payload, unsigned int length) 
      String msgString; 
      {                                                     //put this in a sub block, so any unused memory can be freed as soon as possible, required to save mem while sending data
        char message_buff[length + 1];                      //need to copy over the payload so that we can add a /0 terminator, this can then be wrapped inside a string for easy manipulation.
        strncpy(message_buff, (char*)payload, length);      //copy over the data
        message_buff[length] = '\0';                        //make certain that it ends with a null         
        msgString = String(message_buff);
        msgString.toLowerCase();                            //to make certain that our comparison later on works ok (it could be that a 'True' or 'False' was sent)
      int* idOut = NULL;
      {                                                     //put this in a sub block, so any unused memory can be freed as soon as possible, required to save mem while sending data
        int pinNr = Device.GetPinNr(topic, strlen(topic));
        Serial.print("Payload: ");                          //show some debugging.
        Serial.print("topic: ");
        if (pinNr == ledPin)       
          if (msgString == "false") {
            digitalWrite(ledPin, LOW);                      //change the led    
            idOut = &ledPin;                                
          else if (msgString == "true") {
            digitalWrite(ledPin, HIGH);
            idOut = &ledPin;
      if(idOut != NULL)                                     //also let the iot platform know that the operation was succesful: give it some feedback. This also allows the iot to update the GUI's correctly & run scenarios.
        Device.Send(msgString, *idOut);    


    Similar projects you might like

    Automation of ventilation system

    Project tutorial by Team iMinds-iot

    • 7 respects

    Hot Water Solar Boiler Project

    Project in progress by Pleemans

    • 25 respects

    Home Automation Using Raspberry Pi 2 And Windows 10 IoT

    Project tutorial by Anurag S. Vasanwala

    • 706 respects

    WARAN - Home Automation

    Project tutorial by Arjun Ganesan

    • 77 respects

    Solar UPS controller/automatic transfer switch 

    Project in progress by Markus Loeffler

    • 67 respects

    Sliding Gate Automation

    Project tutorial by Lasith Ishan Premaratne

    • 34 respects
    Add projectSign up / Login