Easiest way to send data off-site for analysis

We are working on a research project with a small business to optimize boiler combustion. We’re trying to figure out the easiest way to send data off-site for analysis. We are comfortable writing Python code and SQL queries, but are not familiar with Ignition.

It seems that the easiest thing to do is to establish a Database Connection to a MySQL DB. After that, how do we actually send data to the DB? Do we write a Timer script to run on the Gateway?

Any advice or suggestions would be appreciated. Thank you.

Kenneth Chiu
Binghamton University

You can use the Tag history or Transaction groups, probably the easiest way, but you can also create your own table structure and then use a gateway even script with system.db.runPrepUpdate or system.db.runNamedQuery. Since you are comfortable with SQL that might be the way you want to go. The bonus for the write your own query method is you don’t need to purchase the SQL Bridge or Tag History modules, if you don’t already have them.

Welcome to the forum!

1 Like

Thanks! I think we’ll try to the gateway script, at least for now. So by “gateway event script”, you are referring to Tag Event Scripts, correct? If a tag value changes rapidly, is there a chance of data loss, or does Ignition do some internal buffering of a tag value’s change events?

You actually want to use a gateway event script. Navigate to Scripting > Gateway Events > Tag Change. I wasn’t quite sure how often you needed to record your data, but it sounds like a tag change event is what you want. I don’t have an example readily available but i do have one for a Scheduled event. This is the script i use to record power usage every quarter hour 00, 15, 30, and 45 minutes.

	tagPath = ["[default]ION/ION_Admin_KWH",
	values = system.tag.readBlocking(tagPath)

	for x in range(len(tagPath)):
		system.db.runPrepUpdate("INSERT INTO kwh_log (tag, value) VALUE (?, ?)", [tagPath[x], values[x].value], "ION_MeterData")

Using a tag change event is actually easier since you don’t need to build the whole list of tag paths. Also, if your data changes very rapidly i believe you may miss events, i think there are some limitations on the actual speed the tag scan class can actually achieve. I am not 100% on that one though.

1 Like

Awesome! This is very helpful and points us in the right direction.

1 Like