# MaraX Temperature Monitoring



## siliconslave (Feb 18, 2020)

Controversial in some circles, but personally I love a dashboard so i'm building a temperature monitor dashboard using the instructions on reddit / github. Figured i'd put the progress on here as help to others that may want to try. Credit to reddit & reddit for instructions & thanks to @*Willem *for his Starter Kit thread, without which i'd never be able to find anything.

*Step one* is to connect to the MaraX and make sure the cable works, you'll need the following:



MaraX


Serial to USB Debug cable - using the PL2303TA chip (https://smile.amazon.co.uk/gp/product/B01N4X3BJB/)


Philips screwdriver


To do this you need the machine on its back / top & remove the bottom plate (make sure you take the water out!) Unscrew the base plate and admire its guts










Locate this port on the left, below the green plugs (if the machines facing away from you on its back) You want the Green wire from your USB cable in the 3rd Pin and White wire in the 4th (counting from outside to in)










Theres a handy cutout in the base you can pull out with some pliers to route the cable through and I electrical taped it down so i didn't pull it out later :

















To check its working on a windows computer you need Putty - you can download it here: https://www.putty.org/

Plug the USB into your computer and check which COM port its running on by going to windows settings & devices, it should appear in that list as '... USB to Serial Comm port (COMx)' in my case x was 3.

Open Putty, select serial, enter your COM port and click Open:

















You should get a stream of dull numbers that, thanks to reddit, mean:



> C1.19 - C for Coffee, 1.19 is the software version. This can also be V for Vapour (Steam) if the machine is in Steam priority mode.
> 
> 118 - This is the real/actual steam temperature in Celsius.
> 
> ...


 *Step two* is setting up the Raspberry Pi for Docker & deploying the grafana dashboard software to visualise the data. That will come tomorrow / later this week when my Pi turns up


----------



## siliconslave (Feb 18, 2020)

Took a little longer than i'd have liked, wife had some holiday so I didn't have any spare time to play with stuff 

I decided to go with a Raspberry Pi zero - partly for the size but also for the price, £12 for wireless version with headers









The only downside with this is that the architecture and power doesn't support the fancy dashboards detailed on reddit (i found after bashing my head against docker for a few hours) But who wants pretty graphs (grr) we can still do some neat stuff 

so:* Step Two - setting up the pi*

Setup and image the Pi with some sort of OS (details in spoiler)



Spoiler



You'll need a Micro SD card & micro USB power supply power supply.

With your computer download and install the latest version of Raspberry Pi OS on the SD card - easiest way is using the imager from here: https://www.raspberrypi.org/downloads/ and personally i used Raspberry Pi OS (32-bit) Lite.

you'll need to enable remote access (if your not going to use a screen and keyboard...) theres a guide here: https://www.raspberrypi.org/documentation/remote-access/ssh/

so on mac you can do:



touch /Volumes/boot/ssh


touch /Volumes/boot/wpa_supplicant.conf


then edit wpa_supplicant.conf to add your wireless network:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="wifi_network"
psk="password"
}

you can (safely) eject the SD card, plug it into your pi and start it up.

from a terminal ssh to the mac



ssh [email protected] raspberry


You'll need to accept the finger and log in - default password is raspberry

best practice is to change the password so:



sudo sudo raspi-config


and select change password. Its also worth expanding the file system (under advanced in that config). After rebooting its worth updating & upgrading using apt-get



sudo apt-get update -y


sudo apt-get upgrade -y





Once the Pi is setup i'm going to use Python and a few widgets to grab the temperature stream, make it pretty and alert me when the machines upto temperature 

1st - select python 3 as default:



nano ~/.bashrc


add the following at the bottom then hit control s then control x to the save and exit




alias python='/usr/bin/python3'



alias pip=pip3


Now we need to install pip3  and restart bash so our new commands work



sudo apt-get install python3-pip


source ~/.bashrc


finally were going to install pyserial and Notify Run



pip install PySerial


pip install notify_run


To setup Notify Run we need to run:




notify-run register


This will show a QR code - scan that with your phone and accept to receive the notifications 

Finally create and run the python script



nano maraXMonitor.py


this is the (shoddy) code i'm using - if you know python please forgive this rusty coder, but it works 



Spoiler



import serial
import time
from notify_run import Notify 
from datetime import datetime

def PrettyPrint(x):
# print the array out nicely

if x[1].startswith('C'):
priorityMode = 'Coffee Priority'
else:
priorityMode = 'Steam Priority'

if x[6]=="0":
heating = "Heater Off"
else:
heating = "Heater On"
m,s = divmod(int(x[5]), 60)
print ('MaraX V'+x[1][1:]+" in "+priorityMode+ " Steam="+x[2]+"/"+x[3]+"C Brew water="+x[4]+"C Fast Heating "+str(m)+":"+str(s)+"s "$

#setup notify
notify=Notify()
#grab the serial stream
ser = serial.Serial('/dev/ttyUSB0', 9600)
sent_alert = False
#loop away! 
while True:
#import the new data from the serial line, time stamp it and clean it up
data = str(ser.readline())
if data:
now = datetime.now()
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
data_array= str(dt_string+","+data[2:-5]).split(",")
#print it out
PrettyPrint(data_array)
#alert if the brew temp is about 84 - need to play with this a bit more 
if not sent_alert :
if( int(data_array[4])>84 and int(data_array[5])==0):
print ("coffees ready!")
notify.send('☕☕☕ Coffee Time! ☕☕☕') 
sent_alert=True
if int(data_array[4])<82:
sent_alert=False

#sleep for a second
time.sleep(1)



You can run it with



python maraXMonitor.py


which should give you something like this:









its set to alert as the brew temp gets to 84c but thats a work in progress, need to work out when the machine thinks its ready 









step three (in another few weeks) is attaching a screen on & maybe attach the timer switch


----------

