I have a Raspberry Pi 3 with a 16 channel Analog hat (2 x MCP3008’s) that I would like to use to monitor the energy used at my house. My thought was to take the readings and send them to emoncms. This seems to be the best way to store and display all the energy data. I’ve looked through the forum and supporting documentation (as best I could), but can’t seem to find where I would edit the code to tell it how to communicate with my setup.
I’m able to communicate with the Analog Hat, but not sure how to pass those readings to the emon system.
I imagine there is already some documentation about this, but can’t seem to find it. Any recommendations?
Disclaimer: I am not a RPi expert, nor a Linux expert.
From what I can see, your Analogue Hat is an ADC only. I looks to me as if you’ll need to write a service to read and process the analogue signals in much the same way as we do in the emonTx with the Atmel ATMega328P processor and emonLib, then send the processed values (usually average power over the last n seconds) to emonHub.
It may have been done by someone here, but I can’t remember seeing anything like it. Have you searched the Archive too?
Exactly. I can write a service to read and process the analogue signals, I am just not sure how to send the values to emonHub. If I knew which files had the code that handled this, I could probably figure it out. I searched through the forum for what I could think was the right question, but sometimes it’s all in how you phrase it. Someone with knowledge of the file system could probably say, “oh ya, file xyz.py has the code that takes the processed values and sends them to file abc.123 and then they go to emonHub.”
Obviously, your profile didn’t give me any sort of clue about your competencies, so - given that no-one else had picked your question up - I had to write a fairly general reply, if only to let you know that you hadn’t been completely ignored.
I’m unsure of my ground here, Paul (@pb66) is the expert as he wrote emonHub, but I think it should be case of launching the values onto an input stream that has been configured in emonHub with an interfacer. Paul will get notified so, work commitments permitting, he may be able to help.
I had a python script, that read values from serial input (I had Arduino connected over USB Serial sending data to BBB). Create a python file; then chmod +x post.py; then either run it manually or have it start with you linux system, I had I auto start and run continuously in the background.
let me know if you need help with any particular parts of the script Rpost.txt (1.8 KB)
The easiest way to get custom data into the emoncms eco-system is to use a Socket interfacer with emonHub.
If you search this forum and the old one for “Socket Interfacer” there are several examples. It basically allows you to post space separated values to a port and emonhub will manage the rest.
The data can be sent to the socket from any language but there are examples of both Bash and Python out there, how are you currently accessing the ADC hat?
The Socket interfacer is useful in it’s own right for prototyping and “one of’s” but it can also pave the way to writing a custom emonhub interfacer which I think this project is ideal for to allow users to easily add an “ADC hat” to a Pi running emonHub/emonSD.
Thank you so much for that post. This would definitely work to get data to emoncms. Paul’s suggestion with the Socket Interfacer sounds like it may be the best option as it should utilized the existing buffer features and all that. But worst case, I can rig something together with a custom script.