Saturday, January 7, 2017

Alexa Enabled Terrarium Temperature Monitor

I recently acquired a Hogg Island boa constrictor. An important part about keeping these types of snakes is maintaining a temperature gradient across the enclosure so the snake can thermoregulate. I had a couple TTF-103 thermistors laying around so I thought it would be cool to set up a temperature monitoring system.


I decided to use the Arduino Yun I had on hand to collect the data and make it available on the internet. A quick Google search for "TTF-103 arduino" and I found some code to convert the readings from the thermistor to temperature. I added some code to log readings from two thermistors to the SD card on the Linux side of the Yun.

    File dataFile = FileSystem.open("/mnt/sd/temperature.log", FILE_APPEND);
    if (dataFile) {
         dataFile.println(getTimeStamp()+","+String(ADCPin)+","+String(fTemp,4));
         dataFile.close();

  }




I put the Yun in a Radio Shack project box and attached it to the back of the snake's enclosure with velcro.

I used regular old scotch tape to attach the thermistors inside the enclosure.



Initially I created a page using jpgraph that displays the temperature readings of both sides of the enclosure .

This was working fine, but wouldn't it be cool if I could just ask the terrarium what the temperature was like? Enter Alexa. It was actually easier than I thought to get a custom skill up and running using the Amazon documentation. The biggest issue I had was trying to get Amazon to use a page served from the web server on the Yun. No matter what I did it complained about the security of the SSL certificate I was using. I ended up finding an Amazon Lambda function that acts as a proxy to bypass this security requirement. All that was left was writing a quick page to return the temperature readings in a format that Alexa can understand.

<?php
exec("tail -n 2 /mnt/sd/temperature.log",$lines);
$left = explode(',',$lines[0]);
$right = explode(',',$lines[1]);
$readings = array('left'=>$left[2],'right'=>$right[2]);

$outputSpeech = array("type"=>"PlainText","text"=>"Left side temp ".$readings['left'] ." degrees. Right side temp ".$readings['right'] ." degrees");
$card = array("content"=>"Left: ".$readings['left']." F\nRight: ".$readings['right']." F","title"=>"Temp Readings","type"=>"Simple");
$response = array("version"=>"1.0","response"=>array("outputSpeech"=>$outputSpeech,"card"=>$card,"shouldEndSession"=>true));
header('Content-Type: application/json');
echo json_encode($response,JSON_PRETTY_PRINT);

?>

This produces JSON like this:
{
    "version": "1.0",
    "response": {
        "outputSpeech": {
            "type": "PlainText",
            "text": "Left side temp 76.5225 degrees. Right side temp 81.8562 degrees"
        },
        "card": {
            "content": "Left: 76.5225 F\nRight: 81.8562 F",
            "title": "Temp Readings",
            "type": "Simple"
        },
        "shouldEndSession": true
    }
}




25 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

      JavaScript Online Training in India

      JavaScript Training in India

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete
  10. Awesome blog thankks for sharing 100% virgin Remy Hair Extension in USA, importing from India. Premium and original human hair without joints and bondings. Available in Wigs, Frontal, Wavy, Closure, Bundle, Curly, straight and customized color hairstyles Extensions.

    ReplyDelete
  11. Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.

    ReplyDelete
  12. الرائد افضل شركات تنظيف خزانات المياه يسعدنا ان نقدم لكم افضل خدمات
    شركة غسيل خزانات بالمدينة المنورة تنظيف خزانات بالمدينة المنورة
    افضل شركة تنظيف منازل بالمدينة المنورة شركة تنظيف بيوت بالمدينة المنورة

    ReplyDelete
  13. It is closely related to data mining and mathematical concepts like probability, so a good base in data mining and mathematics will be helpful during the course of data mining. A good base in python also helps. machine learning institute in hyderabad

    ReplyDelete
  14. Thanks for sharing the way to make instant reach towards the customers can be achieved by PPC services, where Pingu provides the value for each and every bid of investment into productive one as a PPC service provider in Chennai.

    ReplyDelete
  15. He had minor drug convictions and some juvenile mischief 카지노 사이트 on his felony record, however nothing about the thirty-year-old suggested that he’d in the future stand among the many most ingenious cheats in gambling history. To drop a complete bunch of coins on the ground of a public place. Additional emoji descriptions and definitions are copyright © Emojipedia. Emoji images displayed on Emojipedia are copyright © their respective creators, except in any other case famous. It feels like may be} combating in opposition to a machine like that, and it's combating again. It can do a high-low the place you should guess if the next roll might be higher or decrease.

    ReplyDelete