Categories for Simplyduino

Reading the not so smart meter

Today I completed another small project. I’ve got this ‘smart meter’ in my house. The smart bit is that automatically sends off the meter data to the network provider. But I can not see the actual power usage from inside my apartment.

My meter has an infrared LED interface (right next to the meter above 1000 imp / kWh), which gives a pulse for every kWh consumed. By measuring the time between pulses and to count I’m on a current consumption in watts (3.6 / pulse duration to be exact).

I already had a sensor network running based on my previous Simplyduino project, so the addition of a new node was a quick job.

The graph shows that it works well. I still can not explain all the peaks, but the high consumption (800W) between 10:30 and 16:00 is my electrical water boiler.  The other major consumers are the refrigerator, the coffee and tea (for short peaks).

Measuring is knowing!

IR sensor diagram (led1 not used for now).

2_Schematic_-__Users_rob_Projects_Arduino_SmartMeter_SmartMeter_smartmeter_sensor_sch_-_EAGLE_7_5_0_Light

 

Closeup of the meter

IMG_3187

 

Sensorium graph:

Chart_-_Sensorium

Simplyduino SPI 32×8 led matrix

I was using LedControl library but I found it horribly slow. It took almost 100 msecs to refresh the display. So I’ve bypassed the library, used my own frame buffer and switched to hardware SPI.The current sketch (you see in the movie) makes use of the buffer shift to update all four displays at once, instead of shifting every row/display separately I’m now pushing screens so fast I needed to introduce a delay(25) between the screen updates (The screen scrolls 1 pixel every redraw).

 

Arduino LT8900 / LT8910 library

Without much ado i present you my public 1.0 version of a library for the low cost LT8900 and LT8910 2.4Ghz tranceiver module for Arduino and Simplyduino.

https://bitbucket.org/robvanderveer/lt8900lib

From the readme:

This is driver library for use with the low cost LT8900 and LT8910 2.4Ghz transceiver modules as found on ebay.

This library was written because I could not found one, and the chips are incompatible with the NRF24L01(+) modules, even though they look very similar.

The library currently supports:

  • setting channel
  • selection of 1Mbps, 250Kbps, 125Kbps and 62Kbps on lt8910 chips.
  • setting syncword
  • setting lt8900 clock speed
  • settings power and gain
  • sending/receiving dynamic sized packets
  • does not use interrupts
  • hardware SPI

DIY Solder Paste Stencils with a Lasercutter

I recently joined a hackerspace and they have some awesome equipment. One of the machines is a 40W laser cutter. I thought it was time for some experimentation!

For my Simplyduino project I needed a new solder paste stencil because the previous one I ordered at OSH Stencils (these guys offer excellent service!)  is missing a few holes for the components I added with PCB version 1.07. While those 3 extra components are very easy to solder by hand I didn’t want to spend any more more on a stencil. I read quite a few articles on the net on the subject of laser cutting your stencils and here’s my formula.

After a few experimental runs, this is my end result, and I am very happy with it:

IMG_1353

There are a little burning marks on the stencil, that’s all!

Configure the cream layer in eagle

DRC__ITEADstudio_DRC___

Export as DXF

First go to layer settings and disable all but the tCream layer. Then go to file > export > DXF..

Eagle__DXF_Converter_and_1_Board_-__Users_rob_Projects_Arduino_SimplyDuino_hardware_Simplyduino_brd_-_EAGLE_7_0_0_Light

 

The important setting is ‘Fill Area’ which automatically forces the ‘Use line widths’.

 

Opening the file in VisiCut

Our lasercutter uses VisiCut as a printer software and I figure out that tool allows me to open .DXF files directly without the fuzz of converting it to PDF or SVG first. Another advantage is that the dimensions of the pcb are not lost, saving me a lot of time aligning the stencil.

IMG_1348

After positioning, go to Mapping en select ‘Engrave All‘. Edit the details of the mapping and change the resolution to 1200 DPI.  Finally, go to Laser Settings and select power 30 and speed 100. These settings work perfectly for me. I used 125micron Mylar sheets available from amazon.co.uk.

Comparison

Commercial (zooming in on the 8 pins of a ATMega328p-au)

Movie_Recording

My results

Movie_Recording

With some minor tweaking thing may get even better.

Results

Check the photo below for solder paste applied to the board with the above DIY stencil. I shot the photo at an angle so you can see the height of the paste applied.  This close up I notice a tiny alignment shift which is entirely my fault, not the stencil!

IMG_1357

After assembly, this looks like this:

IMG_1364(I needed a little rework on the ATMega pins near C2, that kind of messed up the shot )

Conclusion

images

 

How to monitor your Synology NAS Health DIY-Style

While working on my Sensorium monitoring website for the Sensoduino, it occurred to me that i can monitor much more than just the plant moisture level. Why not (ab)use the system for monitoring the server health?

(more…)

Sending mail using PHP templates

For the Sensoduino monitor website ‘Sensorium’ i’ve implemented email notifications. These HTML message are sent whenever a trigger is activated. To avoid endless prototyping I wanted to use the php engine itself to come up with the email.

Sensorium_trigger_alarm_for_Moisture_Level_of_Sample_HUB_—_Trash

I made a php page named ‘NotificationTemplate.php’ and added some code to fill a few default variables. Also, the template includes shared header and footer file to allow the mail template to be reused.

<?php

require_once __DIR__.'/../config.php';

if(!isset($triggerInfo))
{
        class dummyData
        {
                public $TriggerID = "X";
                public $SensorDescription = "[SENSOR NAME]";
                public $Threshold = "[THRESHOLD]";
                public $MetricDescription = "[METRIC NAME]";
        }

        $triggerInfo = new dummyTrigger();
        $active = true;
        $triggerType = "[IS ABOVE]";
        $logoImageSrc="../images/Sensorium@2x.png";
        $poweredByImageSrc="../images/PoweredBySimplyduino@2x.png";
}

$url = HOME_URL . '/notifications.php';

include 'MailHeader.php';
?>

<p>
Hi,
</p>
<p>
The sensor <b><?php echo $triggerInfo->SensorDescription; ?></b> has reported that the <b><?php echo $triggerInfo->MetricDescription;?></b> <?php echo $triggerType;?> <?php echo $triggerInfo->Threshold; ?>.
</p>
<p>
Sensorium.
</p>
<?php

include 'MailFooter.php';

?>

To use this template, it needs to be ‘rendered’. Below is a fragment from my ‘sendNotification’ method that initialises a few variables and renders the above template file to a string:

$logoImageSrc = "cid:logo_sensorium";
$poweredByImageSrc = "cid:logo_powered";

//construct the message by loading running a template
ob_start();
        
require 'Templates/NotificationTemplate.php';
        
$message = ob_get_contents();
ob_end_clean();

 

The $logoImageSrc variable is used to switch between inline image attachments. As you can see in the template it is given a default if $triggerInfo was not defined.

This way the message can be preview in the browser by directly opening the php file in Safari. I am still figuring out a way to automatically convert the inline images to attachment because it will clean up the code.

Now that we have the messagebody captured in $message, we can easily send the mail by the php mail() method, or even better use phpMailer.

Sensorium for Simplyduino

As a way to demonstrate the possibilities of the Simplyduino I am writing a monitoring website called ‘Sensorium’ (the hub for all sensors).Below are a few screen shots of the mockup site.

Sensorium_-_Index

The app relies on an Arduino rigged as a bridge-node that forwards the sensor metrics to the website using http requests. This way the system does not need any complete USB or Serial port handling, which makes it possible to run the website on any server in the world.

Sensorium will send notifications (by email) when one of your sensors reaches a configurable state. In a future version these notification should also be able to send out triggers to drive the output drivers of the Sensoduino, for example to turn on a light when garage door opens. Now I realise this is a bad example and could be better done by the Arduino directly, but this approach makes it possible to have complex and configurable logic taken outside the Arduino and into the ‘internet of things’.

Sensorium_-_Chart

Check here for more info about the Simplyduino project.