> TC74
home / infca / tc74 (navigation links) We do die multiple times before we truly lay in our graves

P1 | dht22 Links | End

TC74 i nodejs al R3

go 2 top
Homepage, documentation

TC74 pinout TC74 case
TC74 amb nodejs

En MTV em presenta el TC74.

So the maximum bus length of an I2C link is about 1 meter at 100 Kbaud, or 10 meters at 10 Kbaud. url

Llegirem la temperatura mitjançant python i la servirem mitjançant nodejs : { tc74 @ odin }

repositori github, npm i codi nodejs

El entorn és :

sag@odin:~/tc74 $ node -v v11.13.0 sag@odin:~/tc74 $ npm -v 6.9.0 sag@odin:~/tc74 $ git --version git version 2.1.4

Anem fent :

sag@odin:~/tc74 $ git init Initialized empty Git repository in /home/sag/tc74/.git/ get .gitignore edit .gitignore sag@odin:~/tc74 $ git remote add origin https://github.com/sebastianet/tc74 sag@odin:~/tc74 $ git remote add origin https://user:pwd@github.com/sebastianet/tc74.git sag@odin:~/tc74 $ git remote -v origin https://github.com/sebastianet/tc74 (fetch) origin https://github.com/sebastianet/tc74 (push) sag@odin:~/tc74 $ git push -u origin master error: src refspec master does not match any. error: failed to push some refs to 'https://github.com/sebastianet/tc74' sag@odin:~/tc74 $ git commit -am "v1.0 - save units to github" [master (root-commit) 97e4373] v1.0 - save units to github 2 files changed, 37 insertions(+) create mode 100644 .gitignore create mode 100644 servidor.js sag@odin:~/tc74 $ git push -u origin master To https://github.com/sebastianet/tc74.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/sebastianet/tc74.git' hint: Updates were rejected because the remote contains work that you do not have locally. sag@odin:~/tc74 $ git pull origin master warning: no common commits remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/sebastianet/tc74 * branch master -> FETCH_HEAD * [new branch] master -> origin/master Merge made by the 'recursive' strategy. README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md sag@odin:~/tc74 $ git push -u origin master Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 1023 bytes | 0 bytes/s, done. Total 6 (delta 0), reused 0 (delta 0) To https://github.com/sebastianet/tc74.git cb55695..a41b065 master -> master Branch master set up to track remote branch master from origin.

Tenim el repositori funcionant.

codi nodejs

Tenim el codi al R3 i a github

Ara ajustem el npm, manegador dels paquets de nodejs que farem servir.

sag@odin:~/tc74 $ npm init -> package.json

Si en engegar la aplicacio tenim aquest error : "Error: Cannot find module 'express'" es que hem de instalar el modul :

sag@odin:~/tc74 $ npm install -g express --save // install "global", save in "package.json" + express@4.17.1 added 50 packages from 37 contributors and audited 50 packages in 7.283s found 0 vulnerabilities

Si en engegar la aplicacio tenim aquest error : "Error: Cannot find module 'python-shell'" ....

Per engegar manualment l'aplicacio, fem "npm start"

sag@odin:~/tc74 $ npm start > tc74@1.0.0 start /home/sag/tc74 > node servidor.js temperature express server v 1.0 listening on port [8123]. 2020/07/07 - 15:11:57 - +++ /get temp, gimme json 2020/07/07 - 15:11:57 - (+1) python temperature (31).

Fem que la APP engegi amb el R3 using "/usr/bin/odin_restart", i és accessible per tot el mon a myraspiodin


... precedidos por los dioses, avanzaron lentamente apoyados en sus bastones, frenados por el peso de los años y fatigados por la interminable cuesta


Amunt! Top Amunt!
canvas

The improvement is

  1. al servidor obtenir les N darreres lectures
  2. al client HTML afegir un canvas
  3. al client js afegir un codi que cada M minuts obtingui les darreres N lectures del servidor
  4. al client js afegir un codi que construeixi una gràfica amb aquestes lectures directament sobre el canvas o usant una llibreria com canvasjs

DHT22

datasheet

Amazon : El chip principal es el sensor de humedad de temperatura alta sensibilidad AOSONG AM2302.

Comparacio

Com es mesura si es millor el DHT22 que el TC74 ?

internet paso a paso : xips + 5 projectes !


other ways to measure temp

We can use gpio internal devices : CPUTemperature

See /home/sag/tc74/soc_temp.py @ r3 ( version 2.7 only )

sudo apt remove python-pip sudo apt autoremove sudo pip install gpiozero sudo pip install vcgencmd python3 -m pip install ifaddr

Using VanillaJS means using plain JavaScript without any additional libraries like jQuery.


Links
Links DHT22


Ep ! Valid HTML 4.01!   Valid CSS! Escriu-me !
Updated 20201214 (a)  
Uf !