Mkr Env Shield Not Working

Using the example code given at the bottom of https://www.arduino.cc/en/Guide/MKRENVShield, and the best wiring I could find given the horriffic insturctions there, any call to ENV (such as if (!ENV.begin()) {}) the Serial output freezes, and it seems that the code does as well. Using the Mega 2560 board, my wiring from Mkr Env to board is 14TX to 1TX, 13RX to 0RX, 12SCL to 21SCL, 11SDA to 20SDA, 10Miso to 50, 9SCK to 52, 8MOSI to 51, 7(Int Pressure) to 22, 6(Int Temperature/Humidity) to 23, and A2 to A2. 5V and GRD are plugged in correctly. Is the code on the guide site outdated or is the wiring wrong?

EisbarGFX: Using the Mega 2560 board, my wiring from Mkr Env to board is 14TX to 1TX, 13RX to 0RX

TX should be wired to RX

Thank you for the quick response, but even after switching those two wires the program still stops at the line if (ENV.begin()) {

You may have other wiring errors.

I do not have the Mega nor the MKR ENV shield to verify.

There is a MKR message board. https://forum.arduino.cc/index.php?board=107.0

.

Thanks. Given the response times of other questions that seems to be a relatively dead forum, but i’ll post there nonetheless. Thanks for the responses.

Why are you using a Mega (5volt logic) with this shield (3.3volt logic). Seems like asking for trouble. Leo..

I've deleted your other cross-post @EisbarGFX.

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

The MKR ENV Shield is designed to be used with the Arduino MKR Boards. This is not only a matter of the convenience of plugging the shield right into the MKR board, rather than having to use a mess of jumper wires to connect it to your Mega. It’s also designed to work with the 3.3 V logic levels of the MKR boards, as is clearly stated on the product page. Your Mega uses 5 V logic levels. If you connect the MKR ENV Shield directly to your Mega, you subject the sensors on the MKR ENV Shield to 5 V, which they are not designed to handle. There is a good chance that doing this will permanently damage the sensors. If you want to connect the MKR ENV Shield to the Mega, you need to use logic level shifters that convert the 5 V levels of the Mega to the 3.3 V levels of the MKR ENV Shield.

I connected my MKR ENV Shield to my Mega via level shifters and did not experience the freeze you reported when I ran that sketch.

The lux sensor (TEMT6000) readings are off because I made a direct connection between A2 on the shield and A2 on my Mega (this is safe because A2 on the shield is outputting an analog voltage between 0-3.3 V). The library’s readIlluminance function is expecting analogRead() to be handling a range of 0-3.3 V rather than the Mega’s range of 0-5 V. That can easily be adjusted for by modifying the sketch or the library.

The pressure sensor readings are not working. If you have warnings enabled (File > Preferences > Compiler warnings), then you will get a clue as to the reason:

E:\electronics\arduino\libraries\Arduino_MKRENV\src\MKRENV.cpp: In member function 'float ENVClass::readPressure(int)':

E:\electronics\arduino\libraries\Arduino_MKRENV\src\MKRENV.cpp:160:65: warning: left shift count >= width of type [-Wshift-count-overflow]

           (i2cRead(LPS22HB_ADDRESS, LPS22HB_PRESS_OUT_H_REG) << 16)) / 40960.0;

                                                                 ^~

The problem is the library’s readi2c function’s return type is int. On the MKR boards, an int is 32 bits, but on the Mega an int is 16 bits. I fixed this by changing the return type of the library’s readi2c function from int to long (which is 32 bits on Mega).

If you are getting different results from what I reported after connecting your MKR ENV Shield either to the Mega via level shifters or to a MKR board, likely you have damaged one or more of the sensors by subjecting it to 5 V and will need to buy a new MKR ENV Shield.