Simple ABP for STM32L0 Discovery kit LoRa running on Arduino IDE


This is some sketch for B-L072Z-LRWAN1 a.k.a STM32L0 Discovery kit LoRa, Sigfox, low-power wireless from ST, This Discovery kit features the all-in-one CMWX1ZZABZ-091 open module by Murata.

This is some sample arduoino sketch you can open my github here

Happy Coding

Salam ngoprek

Cara merubah file .pfx ke crt dan rsa untuk ssl nginx


Catatan pribadi cara merubah file .pfx (biasanya didapat dari pengelola domain) untuk digunakan di nginx web server begini caranya

openssl pkcs12 -in .file.pfx -clcerts -nokeys -out domain.crt

openssl pkcs12 -in file.pfx -nocerts -nodes -out domain.rsa

Langkah selanjutnya tinggal memasukkan crt dan rsa ke nginx config kalian, biasanya ada di /etc/nginx/sites-available/default

Ubah dibagian ini ya

server { listen 443 ssl; server_name domain.com domain.com; 

ssl_certificate /path/to/your/CRT_file/domain.crt; 

ssl_certificate_key /path/to/your/RSA_file/domain.rsa; 

root /var/www/html/; 

index index.html; 

include /etc/nginx/mime.types; }

Done selesai gampang kan?

Happy Coding …

Salam Ngoprek …

Install nodejs di Raspberry pi


Cara mudah install node-red LST di raspberry pi ikuti langkah dibawah ini

curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs 

Mudah bukan

Happy Coding

Salam ngoprek

Cara install docker dan docker-compose di Raspberry pi


Dibawah ini adalah step by step how to install docker dan docker-compose di raspberry pi

//Jalankan perintah dibawah ini satu persatu

//auto install docker di raspberry pi
curl -sSL https://get.docker.com | sh

//menambahkan docker di usermod pi
sudo usermod -aG docker pi

//install beberapa dependenci

sudo apt-get install -y libffi-dev libssl-dev

sudo apt-get install -y python3 python3-pip

sudo apt-get remove python-configparser

//install docker-compose menggunakan pip
sudo pip3 -v install docker-compose

Silahkan tunggu sampai selesai dan pastikan koneksi internet lancar dan boom docker dan docker-compose sudah terinstall

Happy coding

Salam Ngoprek …

How to embed google map at node-red ui template


This is some example how to embed google map at your template for node-red ui dashboard, hope this help and don’t forget to add your own key for google map at gmap template

Good Luck

Happy Coding

Salam ngoprek

[{"id":"cab47749.47c698","type":"inject","z":"322d96d4.be125a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":300,"y":560,"wires":[["c80c476c.d450c8"]]},{"id":"c80c476c.d450c8","type":"function","z":"322d96d4.be125a","name":"map","func":"\nvar latitude =-6.21462;\nvar longitude =106.84513;\n\n\nmsg.payload = {latitude, longitude}\n\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":560,"wires":[["22edf841.88a418"]]},{"id":"22edf841.88a418","type":"ui_template","z":"322d96d4.be125a","group":"8add4fe8.53baf","name":"GMAP","order":3,"width":"6","height":"6","format":"<!DOCTYPE html>\n<html>\n  <head>\n    <style>\n       /* Set the size of the div element that contains the map */\n      #map {\n        height: 100%;  /* The height is 400 pixels */\n        width: 100%;  /* The width is the width of the web page */\n       }\n    </style>\n  </head>\n  <body>\n\n    <!--The div element for the map -->\n    <div id=\"map\"></div>\n \n\n<script>  \n\nvar latitude;\nvar longitude;\n\n(function(scope) {\n        //Have to use $watch so we pick up new, incoming msg's\n        scope.$watch('msg.payload', function() {\n\n        initMap(scope.msg.payload)     \n            \n        })\n\n\n    })(scope)\n    \n\n\n\n// // // Initialize and add the map\n function initMap(data) {\n\n  \n  var latitude = data.latitude\n  var longitude = data.longitude\n  \n  console.log(latitude);\n  console.log(longitude);\n  \n  var jakarta = {lat:latitude , lng: longitude };\n\n\n  var map = new google.maps.Map(\n      document.getElementById('map'), {zoom: 18, center: jakarta, mapTypeId: 'satellite'});\n\n  var marker = new google.maps.Marker({position: jakarta, map: map});\n}\n\n    </script>\n\n    <script async defer\n    src=\"https://maps.googleapis.com/maps/api/js?key=<yourkeyhere>&callback=initMap\">\n    </script>\n\n  </body>\n</html>\n\n\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":690,"y":560,"wires":[["92a07c8.8e7118"]]},{"id":"92a07c8.8e7118","type":"debug","z":"322d96d4.be125a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":870,"y":560,"wires":[]},{"id":"8add4fe8.53baf","type":"ui_group","z":"","name":"Pictures","tab":"c23383c7.b69a7","order":1,"disp":false,"width":"6","collapse":false},{"id":"c23383c7.b69a7","type":"ui_tab","z":"","name":"LIGHTING PLANT","icon":"dashboard","order":2}]

Add map to node-red


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js"></script>

<script>
    (function() {
        const cScope = this.scope;
        setTimeout(function () {
            
        	const map = L.map('mapid').setView([48.204550, 16.364333], 13);
            let marker;
            
        	L.tileLayer('https://{s}.wien.gv.at/basemap/geolandbasemap/normal/google3857/{z}/{y}/{x}.png', {
        		maxZoom: 18,
                subdomains: ["maps1", "maps2", "maps3", "maps4"]
        	}).addTo(map);
        	
        	map.on('click', function(e) {
                cScope.send(e.latlng);
                if (marker) {
                    map.removeLayer(marker);
                };
                marker = L.circleMarker(e.latlng).addTo(map);
            });
            
            setTimeout(function () {
                map.invalidateSize();
            }, 100);
        }, 300);
    })();
</script>

<div id="mapid" style="width: 100%; height: 320px;"></div>

This is some sample ui template for node-red ui, hope this help

Happy Coding

Salam ngoprek

Simple scheduler in node-red


This is sample flow for scheduling task in node-red, i’m using this for controling pump in my diy indoor hydroponics system

[{"id":"7092122b.f6593c","type":"inject","z":"fee8201c.ff1e","name":"timer lamp on","topic":"lamp","payload":"1","payloadType":"str","repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":0.1,"x":460,"y":1660,"wires":[["85b40c2d.7fdcc"]]},{"id":"e3a49fce.3cda7","type":"inject","z":"fee8201c.ff1e","name":"timer lamp off","topic":"lamp","payload":"0","payloadType":"str","repeat":"","crontab":"00 06 * * *","once":false,"onceDelay":0.1,"x":460,"y":1620,"wires":[["85b40c2d.7fdcc"]]},{"id":"85b40c2d.7fdcc","type":"debug","z":"fee8201c.ff1e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":1640,"wires":[]}]

Happy Coding

Salam Ngoprek

Python remove @ attribute xml to json converter


url = "https://data.bmkg.go.id/datamkg/MEWS/DigitalForecast/DigitalForecast-KalimantanTimur.xml" 
response = requests.get(url) 
data = xmltodict.parse(response.content, attr_prefix='', cdata_key='text') 

datajson = (data['data']['forecast']['area'][1]['parameter'][6]['timerange'])

return print(json.dumps())

How to change default vnc display raspberry pi


Your remote VNC to small for you? This some tips to change default vnc display on raspberry pi

Edit /boot/config.txt

And find frame buffer and change like this

framebuffer_width=1280
framebuffer_height=720

And done restart your raspberry pi and connect again using vnc client to raspberry pi

Some additional tips when your vnc client can’t connect to raspberry via vnc

Login to raspi via ssh and restart service

sudo systemctl start vncserver-x11-serviced

Done

Happy coding and salam ngoprek