How to control the LED on an emonTx

With an Arduino, if I want to illuminate the on-board LED I can do so by declaring digital pin 13 as an output and setting it to Hi.

With an emonTx, I can't see how to control individual pins.  From the schematic, I can see that the on-board LED is connected to PB1(OC1A/PCINT1) but I don't understand what this means.  How can my software connect to this point and make it do something?

Hope someone can point me towards the info that I'm missing ...

3chooks's picture

Re: How to control the LED on an emonTx

From the emonTX firmware library I found lines of code that blink the LED (indicates radio transmissions in this firmware)

https://github.com/openenergymonitor/emonTxFirmware

 

const int LEDpin = 9;                                                                                    // On-board emonTx LED

digitalWrite(LEDpin, HIGH); delay(2); digitalWrite(LEDpin, LOW);      // flash LED

 

Hope this gives you a starting point.

Andrew

MartinR's picture

Re: How to control the LED on an emonTx

The quickest way to find out that sort of thing is to look at the example code.

The LED for emonTx is digital pin 9

You might find this useful...

http://openenergymonitor.org/emon/emontx/reference

calypso_rae's picture

Re: How to control the LED on an emonTx

Thanks guys. 

Robin

calypso_rae's picture

Re: How to control the LED on an emonTx

With an emonTx, it's not immediately obvious how to connect to the various digital pins that it supports.  Seven of these pins are taken up by the Serial interface and the RF chip, but that leads seven which are available for the user to use.  But where exactly are they on the board?

Here's a little demo to show these pins connected up and working as intended.  The sketch just drives each of them on in turn to light an LED.

Yesterday, being in need of a couple of LEDs and connector strips, I went to Maplin and B&Q  and returned with industrial quantities of each.  This seemed like a good use for some of them!

(Sorry, I forgot to attach the sketch yesterday)

TrystanLea's picture

Re: How to control the LED on an emonTx

Nice work Robin, I've added a link to the emontx design reference page to your comment here http://openenergymonitor.org/emon/emontx/reference

calypso_rae's picture

Re: How to control the LED on an emonTx

My latest router is based on an emonTx and I needed to gain access to several of the digital IO lines.  There are three switches, three LEDs and two control outputs for hard-wired dump loads.

Sections of in-line header strips provide a convenient way of accessing these lines.  These are soldered into holes in the board as required.  Robert's recently updated diagram in Section 8 of my PV Router article shows all the of connection points.  By populating only the areas that are needed, it's very easy to plug the corresponding cables onto the right pins.  Multi-coloured cable helps too.  All of these items are available from Spiratronix who have recently published their first printed catalog, which is free. 

The attached sketch uses the on-board switches to turn the LEDs on/off.  The same approach could be easily extended for different hardware configurations.  In my case, I'm simply using the digital pins that can be most easily accessed. and will then allocate the pin numbers as necessary within the Router's sketch.  

An emonTx PCB (£3) plus a Atmega chip (£3.50) from the OEM shop, is a very cheap way to build a basic system. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.