DHT11/DHT22 with Raspberry Pi

Hello,
I have 2 sensors running, with 2 separate x.py, but when i run both of them i see a lot of logs in console…

PUB v1/xxxxxxx/things/xxxxxxx/data/3
temp,c=26.0
PUB v1/xxxxxxx/things/xxxxxx/data/4
rel_hum,p=66.0

Anyone knows how to remove it and only send info to Dashboard ??

Thanks

This is the code i´m using, changig GPIO, one is 4 and 1 another 17, (can not find the way to get working in same one…)

import cayenne.client as cayenne
import time
import Adafruit_DHT

time.sleep(60) #Sleep to allow wireless to connect before starting MQTT

MQTT_USERNAME = “xxxxx”
MQTT_PASSWORD = “xxxxx”
MQTT_CLIENT_ID = “xxxxx”

client = cayenne.CayenneMQTTClient()
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

timestamp = 0

while True:
client.loop()
if (time.time() > timestamp + 5):
humidity11, temp11 = Adafruit_DHT.read_retry(11, 4) #11 is the sensor type, 4 is the GPIO pin number that DATA wire is connected to

    if temp11 is not None:
        client.virtualWrite(3, temp11, cayenne.TYPE_TEMPERATURE, cayenne.UNIT_CELSIUS)
    if humidity11 is not None:
       client.virtualWrite(4, humidity11, cayenne.TYPE_RELATIVE_HUMIDITY, cayenne.UNIT_PERCENT)
    timestamp = time.time()

the above code should not print logs.

pi@raspberrypi:~/Luminosity $ python /home/pi/python/tempsensor2.py &
[2] 16893
pi@raspberrypi:~/Luminosity $ Connecting to mqtt.mydevices.com:1883
Connected with result code 0
SUB v1/REMOVED/things/REMOVED/cmd/+
PUB v1/REMOVED/things/REMOVED/sys/model
Python
PUB v1/REMOVED/things/REMOVED/sys/version
1.1.0
pi@raspberrypi:~/Luminosity $ PUB v1/REMOVED/things/REMOVED/data/5
temp,c=26.0
PUB v1/REMOVED/things/9REMOVED8ce4c23d/data/6
rel_hum,p=60.0
pi@raspberrypi:~/Luminosity $
pi@raspberrypi:~/Luminosity $ PUB v1/REMOVED/things/REMOVED/data/5
temp,c=26.0
PUB v1/REMOVED/things/REMOVED/data/6
rel_hum,p=62.0

client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, loglevel=logging.INFO)

you get logs with loglevel=logging.INFO but it is not there in your code.

Yes, i have this problem with, Light sensor i have removed this and its working fine, but With Temp and Hum sennsor. there is no definition of logging or print in the code.
i´m checking if there is something in Adafruit_DHT file but can´t find anything.

here you have channel 3 and 4 publishing data and in the log you shared it is showing channel 5 and 6

Yes, i have 2 .py s 1 is with 3 and 4 and second with 5 and 6, but both are generating logs.

pi@raspberrypi:~/python $ cat tempsensor.py
import cayenne.client as cayenne
import time
import Adafruit_DHT

time.sleep(60) #Sleep to allow wireless to connect before starting MQTT

MQTT_USERNAME = “”
MQTT_PASSWORD = “”
MQTT_CLIENT_ID = “”

client = cayenne.CayenneMQTTClient()
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

timestamp = 0

while True:
client.loop()
if (time.time() > timestamp + 5):
humidity11, temp11 = Adafruit_DHT.read_retry(11, 4) #11 is the sensor type, 4 is the GPIO pin number that DATA wire is connected to

    if temp11 is not None:
        client.virtualWrite(3, temp11, cayenne.TYPE_TEMPERATURE, cayenne.UNIT_CELSIUS)
    if humidity11 is not None:
       client.virtualWrite(4, humidity11, cayenne.TYPE_RELATIVE_HUMIDITY, cayenne.UNIT_PERCENT)
    timestamp = time.time()

pi@raspberrypi:~/python $ cat tempsensor2.py
import cayenne.client as cayenne
import time
import Adafruit_DHT

time.sleep(60) #Sleep to allow wireless to connect before starting MQTT

MQTT_USERNAME = “”
MQTT_PASSWORD = “”
MQTT_CLIENT_ID = “”

client = cayenne.CayenneMQTTClient()
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

timestamp = 0

while True:
client.loop()
if (time.time() > timestamp + 5):
humidity11, temp11 = Adafruit_DHT.read_retry(11, 17) #11 is the sensor type, 17 is the GPIO pin number that DATA wire is connected to

    if temp11 is not None:
        client.virtualWrite(5, temp11, cayenne.TYPE_TEMPERATURE, cayenne.UNIT_CELSIUS)
    if humidity11 is not None:
       client.virtualWrite(6, humidity11, cayenne.TYPE_RELATIVE_HUMIDITY, cayenne.UNIT_PERCENT)
    timestamp = time.time()

can you try running the file as python3 tempsensor2.py

pi@raspberrypi:~ $ python3 /home/pi/python/tempsensor2.py
Traceback (most recent call last):
File “/home/pi/python/tempsensor2.py”, line 2, in
import cayenne.client as cayenne
ModuleNotFoundError: No module named ‘cayenne’

I run it with Python

install the module for python3

cd Cayenne-MQTT-Python
python3 setup.py install

will try but firs need to make Backup of the SdCard, i have 12 Sensors runnig, i do not want start it over…

There is posibility to remove this log without installing pythoin 3?

pi@raspberrypi:~ $ python3 /home/pi/python/tempsensor2.py
Traceback (most recent call last):
File “/home/pi/python/tempsensor2.py”, line 2, in
import cayenne.client as cayenne
ModuleNotFoundError: No module named ‘cayenne’
pi@raspberrypi:~ $ python2 /home/pi/python/tempsensor2.py
Connecting to mqtt.mydevices.com:1883
Connected with result code 0
SUB v1/REMOVED/things/REMOVED/cmd/+

PUB v1/REMOVED/things/REMOVED/sys/model
Python

PUB v1/REMOVED/things/REMOVED/sys/version
1.1.0

PUB v1/REMOVED/things/REMOVED/data/5
temp,c=26.0

PUB v1/REMOVED/things/REMOVED/data/6
rel_hum,p=58.0

i am not sure what you are doing, but that code should not print logs.

i´m just running this script with python /home/pi/python/tempsensor.py
Nothing more.

when I runi t with Sudo it does not work :

pi@raspberrypi:~ $ sudo python /home/pi/python/tempsensor2.py
Traceback (most recent call last):
File “/home/pi/python/tempsensor2.py”, line 2, in
import cayenne.client as cayenne
ImportError: No module named cayenne.client

how and when did you install the cayenne library. Please update and install with:

pi@raspberrypi:~ $ git clone GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API
Clonando en ‘Cayenne-MQTT-Python’…
remote: Enumerating objects: 166, done.
remote: Total 166 (delta 0), reused 0 (delta 0), pack-reused 166
Recibiendo objetos: 100% (166/166), 32.80 KiB | 861.00 KiB/s, listo.
Resolviendo deltas: 100% (77/77), listo.
pi@raspberrypi:~ $
pi@raspberrypi:~ $
pi@raspberrypi:~ $ cd Cayenne-MQTT-Python
pi@raspberrypi:~/Cayenne-MQTT-Python $ python3 setup.py install
running install
error: can’t create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: '/usr/local/lib/python3.7/dist-packages/test-easy-install-1757.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python3.7/dist-packages/

Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or “root” account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

https://setuptools.readthedocs.io/en/latest/easy_install.html

Please make the appropriate changes for your system and try again.